home *** CD-ROM | disk | FTP | other *** search
- /* Web mailing list updater V1.0 */
- /* A script designed to take the output from */
- /* a form & use the output to make a web based */
- /* mailing list. READ the docs!! */
- /* © William P Wilson - 25.10.97 E&OE */
- /* north@lantic16.demon.co.uk */
-
- parse arg filen
-
- nami = strip(filen)
-
- namy = delstr(nami,1,1)
- len = length(namy)
- name = delstr(namy,len,1)
-
- open(pat,'WebChat:htmlpath','R')
- open(kid,'ENV:Webchat.pref','R')
- open(his,'WebChat:HTML/buffer','R')
-
- dest = 'WebChat:HTML/buffer'
- formid = readln(kid)
- path = readln(pat)
- start = 'WebChat:HTML/default-top'
- end = 'WebChat:HTML/default-end'
-
- idch = 0
-
- if open(file, name, 'R') /* opens file */
- then do while ~eof(file) /* repeat until EOF */
- data = readln(file) /* gets data */
- if upper(left(data,7)) = 'FORMID=' then do /* changes first word into caps to check for formid */
- checkid = word(translate(data,' ','=&'),2)
- if upper(formid) = upper(checkid) then
- call getstrings
- end
- end
-
- if idch = 0 then do
- say 'Wrong formid (not 'formid' but 'checkid').'
- exit
- end
- if idch = 1 then do
- open(one,start,'R')
- open(two,dest,'R')
- open(three,end,'R')
- open(html,path,'W')
-
- dig = readch(one,65535)
- next = readch(two,65535)
- never = readch(three,65535)
- new = (dig next never)
-
- writech(html,new)
-
- call close(one)
- call close(two)
- call close(three)
- call close(file)
- call close(end)
- call close(kid)
- call close(his)
- end
- exit
-
- getstrings:
-
- idch = 1
- fdat = translate(data,' ','&') /* this bit of the script was nicked from Mat Bettinson's */
- do i = 1 to words(fdat) /* formdecoder script he wrote for CU-Amiga :) */
- set = translate(word(fdat,i),' ','=')
-
- name = word(set,1) ; res = translate(word(set,2),' ','+')
- ind = 1
- do forever
- pos = index(res,'%',ind)
- if pos = 0 then break
- hex = substr(res,pos+1,2)
- if hex = '0D' then do /* detects newline code & replaces with <BR> */
- inchar = '<BR>'||x2c(hex)
- end
- else do
- inchar = x2c(hex)
- end
- res = left(res,pos-1)||inchar||substr(res,pos+3)
- ind = pos + 1
- end
-
- open(goto,dest,'A')
- if name = 'name' then do
- ma = ('<DT><B>'res' wrote this on '||date()' :</B>')
- writeln(goto,ma)
- end
- if name = 'message' then do
- mz = ('<DD>'res'<BR><P>')
- writeln(goto,mz)
- end
- end
- call close(goto)
- return
-